package cn.itcast.bos.web.action.auth;

import java.util.List;

import org.apache.shiro.SecurityUtils;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import cn.itcast.bos.domain.auth.Function;
import cn.itcast.bos.domain.user.User;
import cn.itcast.bos.web.action.base.BaseAction;

@Controller("functionAction")
@Scope("prototype")
@Namespace("/auth")
@ParentPackage("bos")
public class FunctionAction extends BaseAction<Function> {

	@Action(value = "functionAction_findFunctionsByUserId")
	public String findFunctionsByUserId() {
		User loginUser = (User) SecurityUtils.getSubject().getPrincipal();
		List<Function> fucntions = functionService.findFunctionsByUserId(loginUser);
		getValueStack().push(fucntions);
		return SUCCESS;
	}

	@Action(value = "functionAction_ajaxListhasGenerateMenu")
	public String ajaxListhasGenerateMenu() {
		// 底层 dao 条件 generatemenu = 1 order by zindex desc
		List<Function> fucntions = functionService.findFucntionsByHasGenerateMenu();
		getValueStack().push(fucntions);
		return SUCCESS;
	}

	@Action(value = "functionAction_ajaxList")
	public String ajaxList() {
		// 底层 dao 条件 generatemenu = 1 order by zindex desc
		List<Function> fucntions = functionService.findAllFunctions();
		getValueStack().push(fucntions);
		return SUCCESS;
	}
}
